<%--
   zTree
   Copyright (c) 2013 ISPERP
   Version : 1.0.0
 --%>
<%@ tag language="java" pageEncoding="UTF-8"
	trimDirectiveWhitespaces="true"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<%@ attribute name="id" required="true" type="java.lang.String"
	description="唯一标识."%>

<%@ attribute name="title" required="false" type="java.lang.String"
	description="标题"%>

<%@ attribute name="cssClass" required="false" type="java.lang.String"
	description="class."%>

<%@ attribute name="cssStyle" required="false" type="java.lang.String"
	description="stlye."%>

<%@ attribute name="modal" required="false" type="java.lang.String"
	description="只读readonly或者编辑模式edit，默认为edit"%>


<%@ attribute name="cusDialogSize" required="false"
	type="java.lang.String"
	description="在定义cusFormatterActions为true有效，如果定义此项将会覆盖cusDialogWidth及cusDialogHeight的属性。默认使用normal"%>

<%@ attribute name="cusCreateUrl" required="false"
	type="java.lang.String" description="增加"%>
<%@ attribute name="cusEditUrl" required="false" type="java.lang.String"
	description="编辑"%>
<%@ attribute name="cusDeleteUrl" required="false"
	type="java.lang.String" description="删除"%>

<%@ attribute name="beforeCreateAction" required="false"
	type="java.lang.String" description="在添加前的参数"%>

<%@ attribute name="beforeDeleteFun" required="false"
	type="java.lang.String" description="在删除前的动作"%>
<%@ attribute name="beforeDeleteMessage" required="false"
	type="java.lang.String" description="在删除前的提示"%>

<%@ attribute name="beforeAddHoverDomeFun" required="false"
	type="java.lang.String" description="在删除前的提示"%>

<%@ attribute name="afterActionsSuccess" required="false"
	type="java.lang.String" description="在删除前的提示"%>

<%@ attribute name="showLv1DeleteBtn" required="false"
	type="java.lang.Boolean" description="是否显示一级删除按钮"%>


<c:set var="async" scope="request" />
<c:set var="check" scope="request" />

<c:set var="callback" scope="request" />
<jsp:doBody />

<c:if test="${empty async}">
	<c:set var="async" value="{}" scope="request" />
</c:if>

<c:if test="${empty check}">
	<c:set var="check" value="{}" scope="request" />
</c:if>
<c:if test="${empty edit}">
	<c:set var="edit" value="{}" scope="request" />
</c:if>
<c:if test="${empty view}">
	<c:set var="view" value="{}" scope="request" />
</c:if>
<c:if test="${empty callback}">
	<c:set var="callback" value="{}" scope="request" />
</c:if>
<c:if test="${empty data}">
	<c:set var="data" value="{}" scope="request" />
</c:if>
<c:set var="setting" scope="request"
	value="{'async':${async},'check':${check},'view':${view},'edit':${edit},callback:${callback },data:${data }}" />

<c:set var="cusDialogSize"
	value="${empty cusDialogSize ? 'normal' : cusDialogSize}" />


<c:if test="${empty beforeCreateAction}">
	<c:set var="beforeCreateAction" value="true" scope="request" />
</c:if>

<c:if test="${empty beforeDeleteFun}">
	<c:set var="beforeDeleteFun" value="true" scope="request" />
</c:if>
<c:if test="${empty beforeDeleteMessage}">
	<c:set var="beforeDeleteMessage" value="您确定要删除所选节点及其子节点？"
		scope="request" />
</c:if>

<c:if test="${empty beforeAddHoverDomeFun}">
	<c:set var="beforeAddHoverDomeFun" value="true" scope="request" />
</c:if>
<c:if test="${empty afterActionsSuccess}">
	<c:set var="afterActionsSuccess" value="false" scope="request" />
</c:if>
<c:if test="${empty showLv1DeleteBtn}">
	<c:set var="showLv1DeleteBtn" value="true" scope="request" />
</c:if>

<c:if test="${empty title}">
	<c:set var="showTitle" value="hidden" scope="request" />
</c:if>

<div class="treePanel box n-box no-border">
	<c:if test="${not empty title}">
		<div class="header ${showTitle}">
			<h2>${title}</h2>
		</div>
	</c:if>
	<c:if test="${modal eq 'edit'}">
		<div
			class="ui-helper-clearfix ui-widget-header ui-corner-top elfinder-toolbar elfinder "
			style="padding:3px">
			<div class="elfinder-buttonset" style="cursor: pointer;"
				title="新增下一级" onclick="${id}.create();">
				<span class="elfinder-button-icon elfinder-button-icon-mkfile"></span>
			</div>

			<div class="elfinder-buttonset" style="cursor: pointer;"
				title="编辑所选节点" onclick="${id}.edit();">
				<span class="elfinder-button-icon elfinder-button-icon-edit"></span>
			</div>
			<div class="elfinder-buttonset" style="cursor: pointer;"
				title="删除所选节点" onclick="${id}.delete();">
				<span class="elfinder-button-icon elfinder-button-icon-view-list"></span>
			</div>
		</div>
	</c:if>
	<ul id="${id}" class="ztree  ${cssClass }" style="${cssStyle}"></ul>
</div>
<script type="text/javascript"> 
 var ${id}={}, ${id}= $("#${id}").tree({
  		id:"${id}",
		title:"${title}",
		setting : ${setting},
		actions : {
			cusCreateUrl:"${cusCreateUrl}",
			cusEditUrl : "${cusEditUrl}",
			cusViewUrl : "${cusViewUrl}",
			cusDeleteUrl : "${cusDeleteUrl}",
			beforeCreateAction :${beforeCreateAction},
			beforeDeleteFun:${beforeDeleteFun},
			beforeAddHoverDomeFun:${beforeAddHoverDomeFun},
			beforeDeleteMessage : "${beforeDeleteMessage}",
			afterActionsSuccess:${afterActionsSuccess},
			showLv1DeleteBtn:${showLv1DeleteBtn}
		},
		cusDialog : {
			cusDialogWidth : "${cusDialogWidth}",
			cusDialogHeight : "${cusDialogHeight}",
			cusDialogSize : "${cusDialogSize}",
			cusDialogMax : "${cusDialogMax}"
		}
	});
</script>